import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// element按需引入
import ElementPlus from 'unplugin-element-plus/vite'

// https://vite.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      scss: {
        // 加入一个全局scss索引
        // additionalData:'@import "@/assets/scss/index.scss";'
        additionalData: `
          @use "@/styles/element/index.scss" as *;
          @use "@/styles/global/index.scss" as *;
        `
      }
    }
  },
  plugins: [
    vue(),
    vueDevTools(),
    ElementPlus({
      useSource: true,
      defaultLocale: 'zh-cn',
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      'stores': fileURLToPath(new URL('./src/stores', import.meta.url)),
      'views': fileURLToPath(new URL('./src/views', import.meta.url)),
      'utils': fileURLToPath(new URL('./src/utils', import.meta.url)),
      'icons': fileURLToPath(new URL('./src/components/icons', import.meta.url)),
    }
  },
  server: {
    host: '0.0.0.0',
    port: 3000
  }
})
